<template>
  <view class="x-goods-list">
    <view
      class="_goods-detail"
      v-for="(item, index) in list"
      :key="index"
      :id="'pid' + index"
      @click="onDetail(item)"
    >
      <view class="_goods-img">
        <x-image :src="item.productMainPic" />
      </view>
      <view class="_goods-title">
        <view class="flex1 top">
          <view class="_indent2">
            <text class="title-tag">活动补贴</text>
            {{item.productTitle}}
          </view>
          <view class="tags">
            <view class="tags__item" v-for="(tag,index) in item.tagList" :key="index">{{ tag }}</view>
          </view>
        </view>

        <view>
          <view class="_sold">
            <text>全网低价<text class="text-decoration">¥{{ item.productPrice }}</text></text>
          </view>
          <view class="_goods-price">
            <view class="_lf">
              <text>补贴价 ¥</text>
              <text class="_blod">{{ item.subsidyPrice }}</text>
            </view>
            <view class="_rt">
              已补{{ item.subsidyAmount }}元
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import $sr from '@/utils/x-sr';
import XImage from '@/components/x-image';

export default {
  name: 'XSubsidyGoods',
  components: {
    XImage
  },
  props: {
    list: {
      type: Array,
      default: null
    },
    lineClamp: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {

    };
  },
  computed: {},
  watch: {},
  methods: {
    onDetail(item) {
      $sr.trackProductCard('trigger_sku_component', item);
      uni.navigateTo({
        url: `/pages/transit-product/index?productId=${item.productId}`
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.x-goods-list{
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  ._goods-detail{
    box-sizing: border-box;
    width: 100%;
    margin-bottom: 16px;
    display: flex;
    background: #FFFFFF;
    border-radius: 6px;
    ._goods-img{
      position: relative;
      width: 240px;
      height: 240px;
      margin: 24px;
      border-radius: 6px;
      overflow: hidden;
      ._tips{
        position: absolute;
        top: 0px;
        left: 0;
        min-width: 120px;
        height: 52px;
        line-height: 52px;
        font-size: 24px;
        text-align: center;
        color: #fff;
        font-style: italic;
        background: #FAAB0C;
        box-shadow: 0px 1px 2px rgba(197, 131, 0, 0.31);
        border-radius: 0px 50px 50px 0px;
      }
    }
    ._goods-title{
      background: #fff;
      padding: 20px 24px 24px 0px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      flex: 1;
      ._indent2{
        color: #323233;
        font-size: 28px;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      ._indent1{
        margin-top: 12px;
        margin-bottom: 8px;
        color: #999999;
        font-size: 24px;
        font-weight: normal;
        -webkit-line-clamp: 1;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      ._sold{
        line-height: 32px;
        color: #A4A4A4;
        font-size: 24px;
        margin-bottom: 10px;
      }
      ._red{
        background: #FCE8E4;
        color: $uni-color-primary;
      }
      ._goods-price{
        background: #AF3530;
        border-radius: 6px;
        display: flex;
        align-items: center;
        line-height: 54px;
        overflow: hidden;
        font-size: 24px;
        text-align: center;
        ._lf{
          flex: 3;
          color: #FFFFFF;
          font-weight: bold;
          display: flex;
          align-items: center;
          justify-content: center;
          ._blod{
            font-size: 32px;
          }
        }
        ._rt{
          flex: 2;
          color: #8B6E42;
          background: #F5E6D3;
        }
      }
    }
  }
}

.title-tag{
  color: #FFFFFF;
  background: #C8B38C;
  border-radius: 6px;
  padding: 0 6px;
  margin-right: 6px;
}

.tags{
  display: flex;
  flex-wrap: wrap;
  margin-top: 14px;
  &__item{
    padding: 0 8px;
    border: 1px solid #FCBF9D;
    box-sizing: border-box;
    border-radius: 4px;
    color: #E97E51;
    font-size: 24px;
    margin: 0 13px 13px 0;
  }
}
</style>
